<template>
	<view class="">
		<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :back-top="true">
			<view class="" style="padding-top: 30rpx;">
				<view class="item-con" v-for="(item, index) in dataList" :key="index" @tap.stop="onItemClick(item)">
					<view class="item">
						<view class="item-top flex-row justify-between">
							<view class="item-top-title clamp">{{ item.type }}</view>
							<view class="item-top-right" v-if="item.status == 0">待支付</view>
							<view class="item-top-right" v-else-if="item.status == 1">待接单</view>
							<view class="item-top-right" v-else-if="item.status == 2">已接单</view>
							<view class="item-top-right" v-else-if="item.status == 3">已完成</view>
							<view class="item-top-right" v-else>已取消</view>
						</view>
						<!-- "address":""//地址 -->
						<view class="item-dis clamp2">地址：{{ item.address }}</view>
						<view class="item-bottom flex-row justify-between">
							<view class="item-dis">{{ item.createDate }}</view>
							<view class="btn" hover-class="hover-opacity" v-if="item.status == 0" @tap.stop="payByWx({ id: item.id,money:item.needPay, type: 'list' })">去支付</view>
							<view class="btn" hover-class="hover-opacity" v-if="item.status == 2" @tap.stop="confirmOrder({ id: item.id, type: 'list' })">确认完成</view>
							<view class="btn" hover-class="hover-opacity" v-if="item.status == 1" @tap.stop="cancelOrder({ id: item.id, type: 'list' })">取消</view>
						</view>
					</view>
				</view>
			</view>
		</s-pull-scroll>
		<mix-modal ref="mixModal" title="温馨提示" :text="modalText" @onConfirm="onModalConfirm"></mix-modal>
		<mix-loading v-if="isLoading"></mix-loading>
	</view>
</template>

<script>
import servceMixins from './servce.js';
export default {
	mixins: [servceMixins],
	data() {
		return {
			dataList: []
		};
	},
	onShow() {
		this.refresh();
	},
	methods: {
		onItemClick(item) {
			if (item.pic) item.pic = item.pic.split('|');
			getApp().globalData.detail = item;
			this.navTo('/pages_servce/servce/details');
		},
		pullDown(pullScroll) {
			setTimeout(() => {
				this.loadData(pullScroll);
			}, 200);
		},
		async loadData(pullScroll) {
			const data = {
				uid: uni.getStorageSync('uid'),
				pageNo: pullScroll.page,
				pageSize: '10'
			};
			if (pullScroll.page == 1) this.dataList = [];
			const res = await this.$request('rescue/record', data, { showLoading: true });
			if (res.result == 0) {
				this.dataList = this.dataList.concat(res.data.list);
				pullScroll.endByPage(Math.ceil(res.data.count / 10), res.data.list);
			} else {
				this.$util.msg(res.resultNote);
			}
		}
	}
};
</script>

<style scoped lang="scss">
.item-con {
	padding: 20rpx;
}
.item {
	border-radius: 20rpx;
	padding: 30rpx;
	background: #ffffff;
}
.item-top-title {
	font-weight: bold;
	max-width: 80%;
}
.item-top-right {
	font-size: 26rpx;
	color: #999;
}
.item-dir {
	padding-top: 16rpx;
}
.item-dis {
	padding-top: 16rpx;
	font-size: 26rpx;
	color: #999;
}
.item-bottom {
	padding-top: 20rpx;
}
.btn {
	height: 66rpx;
	line-height: 66rpx;
	font-size: 26rpx;
	color: #ffffff;
	width: 180rpx;
	text-align: center;
	background: #246697;
	border-radius: 33rpx;
}
</style>
